<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    const arr = [5,6,7,8,1,1,1,"hello"];
    console.log(arr);

    const s = new Set([5,6,7,8,1,1,1,"hello"]);

    s.add("hello");
    s.add(1);
    s.add("hello");

    console.log(s);
    console.log(typeof s);

    console.log(s[0]);
    console.log(s[1]);
    console.log(s[2]);
    console.log(s.length);

    console.log(s.size);

    s.forEach((val, idx, self)=>{
        console.log(val, idx, self)
    });

    // for-of语句，遍历的是值

    // for-in语句，遍历的是键

    for(let i of s){
        console.log(i);
    }


    // 不允许重复数据
    // 数组去重
    const arr2 = [1,2,3,4,3,2,1,2,3,4,4,4];

    const norepeat = arr=>[...new Set(arr)];

    console.log(arr2);

    console.log(norepeat(arr2));
    
</script>
</html>